package com.ming.springboot.controller;

import com.ming.springboot.data.BusinessException;
import com.ming.springboot.data.Result;
import com.ming.springboot.data.ResultCode;
import com.ming.springboot.vo.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by mqsi on 2022/5/15 20:01
 */
@RequestMapping("response")
@RestController
public class ResponseController {

	@GetMapping("/getObject")
	public Object getObject(){
		User user = new User();
		user.setUserName("张三");
		return user;
	}

	@GetMapping("/getStr")
	public String getStr(){
		return "Hello World!";
	}

	@GetMapping("getVoid")
	public void getVoid(){

	}

	@GetMapping("/getError")
	public Integer getError(){
		int rst = 9 / 0;
		return rst;
	}

	@GetMapping("/getError2")
	public Integer getError2(){
		throw  new BusinessException(ResultCode.USER_NOT_FIND);
	}

	@GetMapping("/getResult")
	public Result getResult(){
		return Result.success("操作成功");
	}
}
